Ext.define('PJ.view.usermessagemanage.Edit', {
	extend: 'AM.default.DefaultWindowForm',
	alias: ['widget.trainingManagementEdit'],
	requires: ['AM.default.DefaultDateField', 
	           'AM.default.DateTime',
	           'AM.default.jsonp.DefaultSubmitJsonp',
	           'AM.default.DefaultDateField'
	           ],
	modal: true,// 开启不允许点击其他组件
	frame: true,
	notEdit: true,
	width: 300,
	height:190,
	layout: 'form',
	isSame: false,
	overflowY:'auto',
	autoScroll:false,
	initComponent: function(){
    	var me = this;
    	var bt = '<span style="color:red;">*</span>';
        var theDate = new Date();
        theDate.setFullYear(theDate.getFullYear() + 1, 0, 1);
    	me.items= [{
    		defaults: {
    			labelAlign: 'right',
    			labelWidth: 90,
    			columnWidth: .5,
    			padding:"9 0 0 0",
    			readOnly:me.isView
    		},
    		border: false,
    		xtype: "container",
    		width: 270,
    		height:170,
    		layout: 'column',
    		allowBlank: false,
    		items: [{
    			xtype: 'textfield',
    			fieldLabel:bt + '学员账号',
//    			disabled:me.flag==3?true:false,
    			name: 'loginId',
    			allowBlank: false,
    			readOnly:true,
//                listeners: {
//                	change: function(textField){
//                		if(textField.getValue() && textField.getValue().length > 50){
//                			Orchid.alert('提示','该输入项最多输入50个字符！');
//                		}
//                	}
//                },
    			columnWidth:1,
                maxLength: 50
    		},{
    			xtype: 'textfield',
    			fieldLabel:bt + '身份证号',
//    			disabled:me.flag==3?true:false,
    			name: 'paperNum',
    			allowBlank: false,
//    			readOnly:me.isReadOnly,
//                listeners: {
//                	change: function(textField){
//                		if(textField.getValue() && textField.getValue().length > 50){
//                			Orchid.alert('提示','该输入项最多输入50个字符！');
//                		}
//                	}
//                },
    			columnWidth:1,
                maxLength: 50
    		},{
    			xtype: 'defaultDate',
    			fieldLabel:bt + '提任处级时间',
//    			disabled:me.flag==3?true:false,
    			name: 'heldOfficeDateStr',
    			allowBlank: false,
//    			readOnly:me.isReadOnly,
//                listeners: {
//                	change: function(textField){
//                		if(textField.getValue() && textField.getValue().length > 50){
//                			Orchid.alert('提示','该输入项最多输入50个字符！');
//                		}
//                	}
//                },
    			columnWidth:1,
                maxLength: 50
    		},{
    			xtype: 'hidden',
    			name: 'userID'//承办部委IDs
    		}]
    	}];
		this.buttons = [{
			text:"确定",
			scope:this,
//			hidden:me.isReadOnly,
			handler:function(btn){
				var win = me;
				var form = win.down('form');
				var baseForm = form.getForm();
				if (!baseForm.isValid()) {
					return;
				}
				var url = "";
				var params = {};
				url = me.grid.store.updateUrl;
				
				if(gj_onlineLearning_constant.loadType == "jsonp"){
					baseForm.doAction('submitJsonp',{
						submitEmptyText: false,//忽略emptyValue
						url: url,
						params: params,
						success: function(f, action){
							if (action.result.success) {
								Orchid.alert('消息', "操作成功!", function(){
									var gridPanel = win.grid;
									var store = gridPanel.getStore();
									store.reload();
									win.close();
								});
							}else{
								Orchid.alert('消息', action.result.msg||"系统出错,请联系管理员!", function(){
									win.close();
								});
							}
						},
						failure: function(f, action){
							Orchid.alert('错误', action.result.msg||"系统出错,请联系管理员!");
						}
					});
				}else{
					form.submit({
						submitEmptyText: false,//忽略emptyValue
						url: url,
						params: params,
						success: function(f, action){
							if (action.result.success) {
								Orchid.alert('消息', "操作成功!", function(){
									var gridPanel = win.grid;
									var store = gridPanel.getStore();
									store.reload();
									win.close();
								});
							}else{
								Orchid.alert('消息', action.result.msg||"系统出错,请联系管理员!", function(){
									win.close();
								});
							}
						},
						failure: function(f, action){
							Orchid.alert('错误', action.result.msg||"系统出错,请联系管理员!");
						}
					});
				}
			}
		},{
			text: '关闭',
			scope: this,
			hidden:me.isReadOnly,
			handler: this.close
		},{
			text: '关闭',
			scope: this,
			hidden:!me.isReadOnly,
			handler: this.close
		}];
		this.callParent(arguments);
	}
});